var a = getApp();
Page({
    data: {
        nickName: "",
        avatarUrl: "",
        city: "",
        schoolId: "",
        call: "",
        schoolPicker: [ "电器学院", "软件学院", "机械学院", "土木学院" ]
    },
    onShow: function() {
        wx.showLoading({
            title: "数据加载中"
        });
        var e = this;
        wx.cloud.database({
            env: "tangtang-0gijvqhs3851baf6"
        }).collection("user").where({
            _openid: a.globalData.openid
        }).get({
            success: function(a) {
                e.setData({
                    nickName: a.data[0].nickName,
                    avatarUrl: a.data[0].avatarUrl,
                    schoolId: a.data[0].schoolId,
                    call: a.data[0].call
                });
            }
        }), wx.hideLoading();
    },
    schoolPicker: function(e) {
        this.setData({
            schoolId: this.data.schoolPicker[e.detail.value]
        }), wx.cloud.database({
            env: "tangtang-0gijvqhs3851baf6"
        }).collection("user").where({
            _openid: a.globalData.openid
        }).update({
            data: {
                schoolId: this.data.schoolId
            }
        }), wx.showToast({
            title: "工大社区：修改成功",
            icon: "none",
            image: "",
            duration: 1500,
            mask: !1
        });
    }
});